//
//  BaseTC.m
//  YLMainStructure
//
//  Created by Apple on 2017/9/27.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "BaseTC.h"
#import "BaseNC.h"

static BaseTC *_tabbarC;
@interface BaseTC ()

@end

@implementation BaseTC
+ (instancetype)shareInstance {
    
    if(_tabbarC == nil){
      _tabbarC = [[BaseTC alloc] init];
    }
    return _tabbarC;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置tabbar
    if(self.baseTabbar == nil){
        self.baseTabbar =[[BaseTabbar alloc]init];
    }
    [self setValue:self.baseTabbar forKey:@"tabBar"];
    
}

+ (instancetype)tabBarControllerWithAddChildVCsBlock:(void (^)(BaseTC *))addVCBlock
{
    BaseTC *tabbarVC = [[BaseTC alloc]init];
    if(addVCBlock)
        addVCBlock(tabbarVC);
    return tabbarVC;
}

+ (void)restshareInstance
{
    _tabbarC = nil;
}

- (void)addChildVC: (UIViewController *)vc normalImageName: (NSString *)normalImageName selectedImageName:(NSString *)selectedImageName  title:(NSString *)title isRequiredNavController: (BOOL)isRequired
{
    [self addChildViewController:vc];
    vc.tabBarItem = [[UITabBarItem alloc]initWithTitle:title image:[self originImageWithName:normalImageName] selectedImage:[self originImageWithName:selectedImageName]];
    
}


- (UIImage *)originImageWithName:(NSString *)imageName
{
    return [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}



@end
